<template>
    <view class="container">
		<normal-personal-item :dataList="nameList"></normal-personal-item>
		<normal-personal-item :dataList="buildingList"></normal-personal-item>
		<normal-personal-item :dataList="phoneNumberList"></normal-personal-item>
		<!-- <normal-personal-item :dataList="accountTypeList"></normal-personal-item> -->
		<view class="hrs2"></view>
		<normal-personal-item :dataList="myCompanyList"></normal-personal-item>
		<normal-personal-item :dataList="invoiceNumberList"></normal-personal-item>
		<normal-personal-item :dataList="invoiceAddrList"></normal-personal-item>
		<normal-personal-item :dataList="invoicePhoneList"></normal-personal-item>
		<normal-personal-item :dataList="invoiceBankNameList"></normal-personal-item>
		<normal-personal-item :dataList="invoiceBankNumberList"></normal-personal-item>
    </view>
</template>

<script>
	import {
		ONLINE_SERVER_ADDRESS_BASE,
	} from "../../util/network.js"
    export default{
        data() {
            return {
				current: 0,
				nameList: {
					title: "昵称",
					value: "刘子恒"
				},
				buildingList: {
					title: "楼盘",
					value: "中青大厦"
				},
				phoneNumberList: {
					title: "手机号码",
					value: "15319814898"
				},
				accountTypeList: {
					title: "账号类型",
					value: "主账号"
				},
				myCompanyList: {
					title: "我的企业",
					value: ""
				},
				invoiceNumberList: {
					title: "税号",
					value: ""
				},
				invoiceAddrList: {
					title: "单位地址",
					value: ""
				},
				invoicePhoneList: {
					title: "电话号码",
					value: ""
				},
				invoiceBankNameList: {
					title: "开户银行",
					value: ""
				},
				invoiceBankNumberList: {
					title: "银行账户",
					value: ""
				},
            }
        },
		onLoad: async function() {
			let token = uni.getStorageSync('token')
			this.userInfo = uni.getStorageSync('userinfo')
			this.nameList.value = this.userInfo.name
			this.buildingList.value = this.userInfo.title
			this.phoneNumberList.value = this.userInfo.phone
			this.accountTypeList.value = "this.userInfo.accountType"
			this.myCompanyList.value = this.userInfo.invoiceSetting.vatCompanyName
			this.invoiceNumberList.value = this.userInfo.invoiceSetting.taxNo
			this.invoiceAddrList.value = this.userInfo.invoiceSetting.vatCompanyAddress
			this.invoicePhoneList.value = this.userInfo.invoiceSetting.vatPhone
			this.invoiceBankNameList.value = this.userInfo.invoiceSetting.vatBankName
			this.invoiceBankNumberList.value = this.userInfo.invoiceSetting.vatBakAccount
			let _this = this
			uni.request({
				url:`${ONLINE_SERVER_ADDRESS_BASE}/user/show/` + this.userInfo.id,
				header: {
					'Authorization': token,
				},
				method:'GET',
				success: function (res) {
					console.log("用户信息",res.data);
					if(res.data.code == 200){
						if(res.data.data.user.invoiceSetting != null){
							_this.myCompanyList.value = res.data.data.user.invoiceSetting.vatCompanyName
							_this.invoiceNumberList.value = res.data.data.user.invoiceSetting.taxNo
							_this.invoiceAddrList.value = res.data.data.user.invoiceSetting.vatCompanyAddress
							_this.invoicePhoneList.value = res.data.data.user.invoiceSetting.vatPhone.replace('-','')
							_this.invoiceBankNameList.value = res.data.data.user.invoiceSetting.vatBankName
							_this.invoiceBankNumberList.value = res.data.data.user.invoiceSetting.vatBakAccount
						}else{
							uni.showModal({
								content:"获取最新发票抬头失败，请联系管家",
								showCancel:false
							})
						}
					}
				}
			})
			console.log('ceshi',this.userInfo)
		},
    }
</script>

<style>
	.container {
		background-color: rgba(242, 241, 239, 1.0);
		padding-bottom: 80rpx;
	}
    .item-table{
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
	.hrs2 {
		margin-top: 20rpx;
	}
</style>